<template>
	<el-form
	    :label-position="labelPosition"
	    label-width="100px"
	    style="max-width: 350px;margin: 0px auto;"
	>
	<el-form-item label="文档标题">
    <el-input placeholder="请输入文档名称" v-model="document.documentName"/>

  </el-form-item>
	<el-form-item label="文档类型">
		<el-input  placeholder="请输入文档类型" v-model="document.documentClass"></el-input>
	</el-form-item>
   	<el-form-item label="文档状态">
			<el-radio-group v-model="document.documentState">
			      <el-radio label="公开" size="large" border>公开</el-radio>
			      <el-radio label="私密" size="large" border>私密</el-radio>

			</el-radio-group>
		</el-form-item>


	<el-form-item label="文档">
		<el-upload
		    ref="uploadRef"
		    class="upload-demo"
		    action="http://localhost:8080/document/upload"
		    :auto-upload="true" :on-success="successUpload">
		    <el-button type="primary">选择文件</el-button>

		</el-upload>
	</el-form-item>

		<el-button type="primary" @click="submit">确定</el-button><el-button @click="cannel">取消</el-button>

	</el-form>

</template>

<script>
import qs from 'qs'
	export default {
		data() {
      return {
        document: {}
      }

    },

		methods:{
      submit(){
        let u=JSON.parse(sessionStorage.getItem("user"))
        this.document.userId=u.userId
        var _this = this;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth()+1;
        let dd = new Date().getDate();
        let hh = new Date().getHours();
        let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();
        let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();
        _this.document.documentDate = yy+"-"+mm+"-"+dd;

        console.log(this.document)
        let that=this
        let str=qs.stringify(that.document)
        that.$axios.get("http://localhost:8080/document/documentcreat?"+str).then(function(res){

						ElMessage({
							message: '上传成功！',
							type: 'success',

						})
						// 删除弹框的遮罩层
						that.updatedialogFormVisible = false
						that.deptsList()
					
        })
      },
      cannel(){
        this.$router.push("/index")
      },
      successUpload(res){
        this.email.url=res
        console.log(res)
      }

		}
	}


</script>

<style>
</style>
